package com.sj.parksdk.adapter.carmanage;

import android.view.View;

import androidx.annotation.NonNull;

import com.ruffian.library.widget.RTextView;
import com.ruffian.library.widget.helper.RTextViewHelper;
import com.sj.parksdk.R;
import com.xuexiang.xui.adapter.recyclerview.BaseRecyclerAdapter;
import com.xuexiang.xui.adapter.recyclerview.RecyclerViewHolder;
import com.xuexiang.xui.utils.ResUtils;
import com.xuexiang.xutil.common.StringUtils;

public class AdapterCarLetter extends BaseRecyclerAdapter<String> {

    public AdapterCarLetter(String[] data) {
        super(data);
    }

    private String  letterType = "letter";

    public AdapterCarLetter setLetterType(String letterType) {
        this.letterType = letterType;
        return this;
    }

    @Override
    protected int getItemLayoutId(int viewType) {
        return R.layout.parksdk_adapter_add_car_letter_item;
    }

    @Override
    protected void bindData(@NonNull RecyclerViewHolder holder, int position, String item) {

        RTextView rtv = holder.findViewById(R.id.rtv_item);
        rtv.setText(item);
        RTextViewHelper helper = rtv.getHelper();
        if("letter".equals(letterType)){
            helper.setBackgroundColorNormal(ResUtils.getColor(R.color.color_white));
        }else if("type".equals(letterType)){
            helper.setBackgroundColorNormal(ResUtils.getColor(R.color.color_light_gray));
        }
        if("I".equals(item) || "O".equals(item)){
            helper.setTextColorNormal(ResUtils.getColor(R.color.color_9));
        }else{
            helper.setTextColorNormal(ResUtils.getColor(R.color.color_3));
        }
        if(StringUtils.isEmpty(item)){
            rtv.setVisibility(View.GONE);
        }else{
            rtv.setVisibility(View.VISIBLE);
        }
    }
}
